/*!
// Testweb v0.4.0
// http://or-change.cn
// Copyright 2014 OrChange Inc. All rights reserved.
// Licensed under the GPL License.
*/
define(function (require, exports, module) {
	'use strict';
	var helper = require("model/helper"),
		OC = require("lib/core/oc");
	exports.execute = function (me, $, load) {
		return function () {
			helper.moveToCenter(me);
			
			$(document).keydown(function (event) {
				if (event.keyCode == 13 ){
				$("#enter").click();
				}
			});
			$("#enter").click(function () {
				var key, token, data = {};
				key = $("input").val();
				token = OC.getToken();

				load.dim.query("getAccess", [token, "AECC9D868BAD1151"], function (access) {
					if (access.success === "true") {
						load.dim.query("getProjectInfo", [token, "AECC9D868BAD1151"], function (project_info) {
							data.project = {
								name: project_info.name,
								author: project_info.author
							};
							data.user = {
								name: access.user
							};
							OC.fanIn(project_info.config);
							load.tpm.close(me);
							load.tpm.open("ui", data);
						});
					}
				});
			});

		};
	};
});